package org.elec.mac.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;

@Slf4j
@Controller
public class IndexController {

    @Value("${tencent.wx.appid}")
    private String appid;

    @Value("${tencent.wx.authorize}")
    private String authorize;

    @Value("${tencent.wx.redirecturi}")
    private String redirect_uri;

    @RequestMapping(value = "/index.do")
    private void indexHandler(HttpServletRequest request, HttpServletResponse response, ModelMap model) throws IOException {
        String user_agent = request.getHeader("User-Agent");
        String mach = request.getParameter("mach");
        String sign = request.getParameter("sign");

        try {
            request.getRequestDispatcher("/weixin.do").forward(request, response);
        } catch (ServletException e) {
            log.error("ServletException : " + e);
            response.sendRedirect("/refuse.html");
        }
    }

}